package com.vms.healthcontrol;

import com.vms.control.weight.App;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

class DBOpenHelper extends SQLiteOpenHelper {

	private static DBOpenHelper instance = null;

	private DBOpenHelper(Context context) {
		super(context, WeightDataSource.WEIGHT_DB_NAME, null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
//		this.dbProvider.netLog.i("onCreate [DB v:%d]", db.getVersion());

		db.execSQL("create table "+WeightDataSource.WEIGHT_TABLE_NAME+" ("
				+ WeightDataSource.ID+" integer primary key autoincrement," 
				+ WeightDataSource.TYPE_NAME +" text,"
				+ WeightDataSource.VALUE+" real,"
				+ WeightDataSource.DAY+" integer"
				+ ");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//		this.dbProvider.netLog.i("onUpgrade [DB v:%d] old v:%d  new v:%d", db.getVersion(),oldVersion,newVersion);
	}

	public static synchronized DBOpenHelper getInstance(Context context) {
		if(instance == null) {
			instance = new DBOpenHelper(context);
		}
		return instance;
	}
}